package com.chushouya.manager.constants;


import com.general.framework.core.enums.IEnum;
import com.general.framework.core.exception.Ex;
import com.general.framework.core.lang.Strings;

import java.util.Objects;

/**
 * 结算业务类型
 */
public enum SettleBizTypeEnum implements IEnum<Integer> {

    STORE_COMMISSION(10, "门店佣金"),
    STORE_WITHDRAW(20, "门店提现"),
    MERCHANT_RECHARGE(30, "商户充值"),
    MERCHANT_WITHDRAW(40, "商户提现"),
    COMMERCE_RECYCLE_DEDUCT(50, "回收扣款"),


    ;


    private Integer bizType;

    private String desc;

    SettleBizTypeEnum(Integer bizType, String desc) {
        this.bizType = bizType;
        this.desc = desc;
    }

    public static String getDesc(Integer bizType) {
        for (SettleBizTypeEnum thisEnum : SettleBizTypeEnum.values()) {
            if (Objects.equals(thisEnum.bizType, bizType)) {
                return thisEnum.desc;
            }
        }
        return Strings.EMPTY;
    }

    public static SettleBizTypeEnum get(Integer bizType) {
        for (SettleBizTypeEnum thisEnum : SettleBizTypeEnum.values()) {
            if (Objects.equals(thisEnum.bizType, bizType)) {
                return thisEnum;
            }
        }
        throw Ex.systemError("未定义的订单结算类型[{}]", bizType);
    }

    @Override
    public Integer value() {
        return this.bizType;
    }

    @Override
    public String named() {
        return this.desc;
    }
}
